using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;

using Gtk;
using Mono.Cecil;
using MonoDevelop.Components.Commands;
using MonoDevelop.Core;
using MonoDevelop.Core.Gui.Dialogs;
using MonoDevelop.Projects;
using MonoDevelop.Projects.CodeGeneration;
using MonoDevelop.Projects.Parser;
using MonoDevelop.Projects.Text;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Pads;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide.Tasks;


namespace MonoDevelop.SmokeyAddin
{
        internal static class ResultsReporter {
                private static TaskService task_service = IdeApp.Services.TaskService;        
                
                public static void BeginInspecting (string entryName)
                {
                        IdeApp.Workbench.StatusBar.BeginProgress (GettextCatalog.GetString ("Inspecting {0}...", entryName));
                        ResultsReporter.task_service.Clear ();
                }                
                
                public static void EndInspecting ()
                {
                       IdeApp.Workbench.StatusBar.EndProgress ();
                }                
                
                public static void ReportViolations (List<Violation> violations)
                {
                       ResultsReporter.task_service.ShowErrors ();
                        foreach (Violation v in violations)
                                ResultsReporter.AddViolation (v);
                }
                
                private static void AddViolation (Violation v)
                {
                        TaskType type = TaskType.Message;
                        if (v.Severity == Severity.Error)
                                type = TaskType.Error;
                        else
                                type = TaskType.Warning;
                        string text = string.Format ("Cause: {1}{0}Description: {2}{0}Fix: {3}", Environment.NewLine, v.Cause, v.Description, v.Fix);
                        foreach (Location loc in v.Locations) {
                                ResultsReporter.task_service.Add (
                                        new Task (loc.FileName, text, 0, loc.Line, type, Inspector.CurrentProject, TaskPriority.Normal));                                  
                        }
                }
        }
}
